package com.darco.darcoapp.db;

import java.util.ArrayList;

import android.content.ContentValues;
import android.util.Log;

public class DarcoDataWorkerThreads {

	public static class InsertUniqueCardThread extends Thread{
		private String sn;
		private String id;
		private int auth;
		private String actual_owner;
		private String first_auth;
		private String first_owner;
		
		private DarcoData darcoDataInstance;
		
		public InsertUniqueCardThread(DarcoData d, String sn,String id,int auth, String actual_owner, String first_auth, String first_owner) {
			this.sn = sn;
			this.id = id;
			this.auth = auth;
			this.actual_owner = actual_owner;
			this.first_auth = first_auth;
			this.first_owner = first_owner;
			
			this.darcoDataInstance = d;
		}
		
		@Override
		public void run() {
			darcoDataInstance.insertUniqueCard(sn, id, auth, actual_owner, first_auth, first_owner);
		}
	}
	
	
	public static class InsertCategoryThread extends Thread{
		private int id;
		private String name;
		private int allowsub;
		
		private DarcoData darcoDataInstance;
		
		public InsertCategoryThread(DarcoData d, int id,String name,int allowsub) {
			this.id = id;
			this.name = name;
			this.allowsub = allowsub;
			
			this.darcoDataInstance = d;
		}
		
		@Override
		public void run() {
			darcoDataInstance.insertCategory(id, name, allowsub);
		}
	}
	
	public static class insertCardListIntoLocalDBThread extends Thread{
		private ArrayList<ContentValues> card;
		private ArrayList<ContentValues> unique;
		private DarcoData d;
		public insertCardListIntoLocalDBThread(DarcoData d,ArrayList<ContentValues> unique,ArrayList<ContentValues> card){
			this.card=card;
			this.unique=unique;
			this.d=d;
		}
		
		public void run(){
			d.insertCardListIntoLocalDB(unique, card);
			Log.d("DarcoData ","Card List insert complete");
		}
	}
	
	public static class InsertCardThread extends Thread{
		private String sn;
		private String name; 
		private String stats;	
		private String special; 
		private int cat;
		private int sub;
		private byte[] preview;
		private byte[] image;
		
		private DarcoData darcoDataInstance;
		
		public InsertCardThread(DarcoData d, String sn, String name, String stats,	String special, int cat, int sub, byte[] preview,byte[] image){
			this.sn = sn;
			this.name = name;
			this.stats = stats;
			this.special = special;
			this.cat = cat;
			this.sub = sub;
			this.preview = preview;
			this.image = image;
			
			this.darcoDataInstance = d;
		}
		
		@Override
		public void run() {
			darcoDataInstance.insertCard(sn, name, stats, special, cat, sub, preview, image);
		}
	}
	
	
	public static class UpdateCardImageInLocalDBThread extends Thread{
		private String sn;
		private byte[] image;
		
		private DarcoData darcoDataInstance;
		
		public UpdateCardImageInLocalDBThread(DarcoData d, String sn, byte[] image) {
			this .sn = sn;
			this.image = image;
			
			this.darcoDataInstance = d;
		}
		
		@Override
		public void run() {
			darcoDataInstance.updateCardImageInLocalDB(sn, image);
		}
	}
	
}
